package vmo;

import java.nio.ByteBuffer;

import client.ColourMap;
import shared.Portrait;
import shared.Vec2f;
import vmo.Tile.TileType;

public class Actor_Player extends Actor_Character {

	PlayerData m_data;

	
	Actor_Player()
	{
		
	}
	
	public Actor_Player(PlayerData data)
	{
		m_type=0;
		m_data=data;
		m_visible=true;
	
	}
	
	public short getEntity()
	{
		return m_data.m_entity;
	}
	
	@Override
	public boolean hasPart(int part) {
		// TODO Auto-generated method stub
		switch (part)
		{
			case 0:
			return true;
		
			case 1:
			if (m_data.m_hairstyle>0)
			{
				return true;
			}
			
			case 5:
			return true;
		
		}
		return false;
	}

	@Override
	public int getSprite(int part) {
		// TODO Auto-generated method stub
		switch (part)
		{
		case 0:
			return (Portrait.getBodyImage(m_data.m_gender))+m_data.m_facing;
		case 1:
			return (m_data.m_hairstyle*4)+m_data.m_facing;
		case 5:
			return 188;
		}
		
		return 0;
	}

	@Override
	public byte[] getColor(int part) {
		// TODO Auto-generated method stub#
		switch (part)
		{
		case 0:
			return ColourMap.getInstance().getColour(m_data.m_skincolour);
		case 1:
			return ColourMap.getInstance().getColour(m_data.m_haircolour);			
		}
		return new byte[]{100,100,100};
	}

	@Override
	public void Update(float dt) {

		// TODO Auto-generated method stub

	}

	@Override
	public int getLayer() {
		// TODO Auto-generated method stub
		return m_data.m_layer;
	}

	@Override
	public Vec2f getPosition() {
		// TODO Auto-generated method stub
		return m_data.m_pos;
	}

	@Override
	public byte getFacing() {
		// TODO Auto-generated method stub
		return m_data.m_facing;
	}



	@Override
	void setFacing(byte direction)
	{
		if (direction!=m_data.m_facing)
		{
			m_data.m_facing=direction;
			if (m_rui!=null)
			{
				m_rui.Redraw();
			}
		}
	
	}	
	

	
	@Override
	void AdjustPos(Vec2f p)
	{
		m_data.m_pos.x+=p.x;
		m_data.m_pos.y+=p.y;
		if (m_rui!=null)
		{
			m_rui.Moved(p);
		}
		
	}
	
	void AdjustPos(float x, float y)
	{
		m_data.m_pos.x+=x;
		m_data.m_pos.y+=y;
		if (m_rui!=null)
		{
			m_rui.Moved(x,y);
		}		
	}	
	@Override	
	void setLayer(short l)
	{
		m_data.m_layer=l;
		m_interface.ForceRebuild();
	}	
	
	
	public void setPos(Vec2f p, byte l) {
		// TODO Auto-generated method stub
		m_data.m_pos=p;
		m_data.m_layer=l;
		if (m_rui!=null)
		{
			m_rui.Moved(p);
		}
	}	
	
	@Override
	public short getUID() {

		return m_data.m_UID;
	}

	@Override
	public void LoadRecord(int offset, byte[] array, Vec2f p, int z) 
	{
		// TODO Auto-generated method stub
		
	}

	@Override
	public byte getAtype() {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void Encode(ByteBuffer buffer) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Vec2f getPriorPos(int v) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setPrior() {
		// TODO Auto-generated method stub
		
	}	
	
}
